<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件绑定</title>
  <style>
    .parent {
      width: 400px;
      height: 300px;
      background-color: cadetblue;
      overflow: hidden;
    }
    .child {
      float: left;
      width: 100px;
      height: 100px;
      background-color: chocolate;
      margin: 10px;
    }
  </style>
  <script>
    function myfun() {
      alert('点击')
    }
    window.onload = function() {
      // 1.获取需要绑定事件的dom节点
      var parent = document.getElementById('parent')
      // 2.给当前dom节点绑定事件
      parent.onclick = function(event) {
        console.log('this',this);
        console.log('目标源元素',event.target);
        console.log('当前触发事件元素',event.currentTarget);
        console.log(this === event.currentTarget);
        // console.log('点击了parent');
      }
    }
  </script>
</head>
<body>
  <div class="parent" id="parent">
    <div class="child">one</div>
    <div class="child">two</div>
    <div class="child">three</div>
  </div>
</body>
</html>